<template>
    <div>
        <!-- seach区域 -->
        <div class="seach">
            <span class="seachStatus">
                {{$t('sta')}}
                <el-select v-model="emailchnForm.status" :placeholder="$t('plsset')" size="mini">
                    <el-option :label="'-' + $t('plsset') + '-'" :value="null"></el-option>
                    <el-option :label="$t('vlid')" value="VALID"></el-option>
                    <el-option :label="$t('invlid')" value="INVALID"></el-option>
                </el-select>
            </span>
            <el-button type="primary" @click="seachemailchnlist" v-preventReClick>{{$t('qury')}}</el-button>
            <!-- <el-button type="warning" @click="showAddNote">{{$t('add')}}</el-button> -->
        </div>
        <!-- 内容区域 -->
        <el-card class="cardBox">
            <el-table border style="width: 100%" :data="emailchnTab">
                <el-table-column type="index" :label="$t('sernum')">
                </el-table-column>
                <el-table-column prop="channelName" :label="$t('chnlnam')">
                </el-table-column>
                <el-table-column prop="channelCode" :label="$t('chnnumber')">
                </el-table-column>
                <el-table-column prop="channelEmailType" :label="$t('chntype')">
                </el-table-column>
                <el-table-column prop="status" :label="$t('sta')">
                </el-table-column>
                <el-table-column prop="address" :label="$t('opratn')" width="120" fixed="right">
                    <!-- <template slot-scope="scope">
                        <el-link type="primary" @click="showEditNote(scope.row)">{{$t('mdfy')}}</el-link>
                        <el-link type="primary" @click="showDel(scope.row)">{{$t('dlte')}}</el-link>
                    </template> -->
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="emailchnForm.pageNum"
                :page-sizes="[10, 15, 20, 30]"
                :page-size="emailchnForm.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
import {
  getemailchnlist
} from '@/libs/reqlist.js'
export default {
  data () {
    return {
      total: 0,
      emailchnForm: {
        account: null,
        channelCode: null,
        status: null,
        pageSize: 10,
        pageNum: 1
      },
      emailchnTab: []
    }
  },
  methods: {
    seachemailchnlist () {
      this.emailchnForm.pageNum = 1
      this.getemailchnList()
    },
    getemailchnList() {
      getemailchnlist(this.emailchnForm).then(res => {
        if (res.data.code === '000000') {
          this.emailchnTab = res.data.data.list
          this.total = res.data.data.total - 0
          this.emailchnTab.forEach(item => {
            if (item.status === 'VALID') {
              item.status = this.$t('vlid')
            } else {
              item.status = this.$t('invlid')
            }
          })
        }
      })
    },
    handleSizeChange (newSize) {
            this.emailchnForm.pageSize = newSize
            this.getemailchnList()
        },
        // 监听总页数变化
        handleCurrentChange (newNum) {
            this.emailchnForm.pageNum = newNum
            this.getemailchnList()
        }
  },
  mounted () {
    this.getemailchnList()
  }
}
</script>

<style lang="less" scoped>
@import './emailchn.less';
</style>
